package it.fuzzylogics.fuzzywidgetsLibrary.client.FuzzyTextbox;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
import com.google.gwt.user.client.ui.SuggestBox;
import it.fuzzylogics.fuzzywidgetsLibrary.client.FuzzyRoundedPanel.FRoundPanel;


public class FRSuggestBox extends FRoundPanel {
    FTextBox fTeXBox;
    SuggestBox suggestBox;

    public FRSuggestBox(MultiWordSuggestOracle oracle, FTextBox textbox) {
        super("img1_text_box.gif", "img2_text_box.gif", "img3_text_box.gif", "img4_text_box.gif", 5, 5, false);
        setTopBorderStyle("titoloRoundPanelBorder1");
        setLeftBorderStyle("titoloRoundPanelBorder2");
        setRightBorderStyle("titoloRoundPanelBorder3");
        setBottomBorderStyle("titoloRoundPanelBorder4");
        fTeXBox = textbox;
        suggestBox = new SuggestBox(oracle, fTeXBox);
        insertContent(suggestBox, 3, 3);
    }

    public String getText() {
        return suggestBox.getText();
    }

    public void setText(String text) {
        suggestBox.setText(text);
    }

    public void setStyleName(String styleName) {
        suggestBox.setStyleName(styleName);
    }

    public void setPixelSize(int w, int h) {
        int fontSize = (h * 12 / 20);
        DOM.setStyleAttribute(suggestBox.getElement(), "fontSize", (fontSize > 6 ? fontSize : 6) + "px");
        super.setPixelSize(w, h > 22 ? h : 22);

    }

}
